home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr32 / moufun.zip / MOUDEMO3.C next >
C/C++ Source or Header  |  1995-04-19  |  3KB  |  120 lines

  1. #include <graph.h>
  2. #include <dos.h>
  3. #include <time.h>
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <bios.h>
  8. #include "mou.h"
  9. #include "moufun.c"
  10. #pragma check_stack(off)      /* turn off stack checks so that functions */
  11.                  /* can be called from interrupt routines   */
  12. void menu1(void);
  13. void menu2(void);
  14.  
  15.     int menone = 'n';
  16.  
  17. void main(void)
  18.     {
  19.     int numbuttons,
  20.         buttonstatus,
  21.         numberpresses,
  22.         pointercol,
  23.         pointerrow;
  24.     char numbuf[3];
  25.  
  26.     /* test ether mouse driver is installed  */
  27.  
  28.     if(!mouinstalled())
  29.       {
  30.        _outtext("SORRY-- a mouse must be installed");
  31.        exit(1);
  32.       }
  33.  
  34.     _clearscreen(_GCLEARSCREEN);
  35.      moureset(&numbuttons);
  36.      moushowpointer();
  37.      printf("+------------------------------------+\n");
  38.      printf("|   MENU 1   |   MENU 2   |   QIUT   |\n");
  39.      printf("+------------------------------------+\n");
  40.      printf("pointer column: xx    row: xx   |"
  41.         "   left button: right button: \n");
  42.  
  43.     for(;;)
  44.        {
  45.         mougetbuttonpress
  46.           (0,
  47.            &buttonstatus,
  48.            &numberpresses,
  49.            &pointercol,
  50.            &pointerrow);
  51.            pointercol /= 8;
  52.            pointerrow /= 8;
  53.  
  54.            _settextposition(5,16);
  55.            sprintf(numbuf,"%2d",pointercol);
  56.            printf(numbuf);
  57.            _settextposition(5,27);
  58.            sprintf(numbuf,"%2d",pointerrow);
  59.            printf(numbuf);
  60.            _settextposition(5,41);
  61.            printf(buttonstatus & LEFTBUTTONDOWN  ? "DOWN":"UP  ");
  62.            _settextposition(5,55);
  63.            printf(buttonstatus & RIGHTBUTTONDOWN ? "DOWN":"UP  ");
  64.            _settextposition(11,12);
  65.            printf("menone is %c",menone);
  66.            if(numberpresses > 0 && pointerrow == 1)
  67.              {
  68.               if(pointercol >= 1 && pointercol <= 12)
  69.             menu1();
  70.               else
  71.               if(pointercol >= 14 && pointercol <= 25)
  72.             menu2();
  73.               else
  74.               if(pointercol >= 27 && pointercol <= 36)
  75.             {
  76.              moureset(&numbuttons);
  77.              _clearscreen(_GCLEARSCREEN);
  78.              exit(0);
  79.             }
  80.         }      /* end if numberpresses > 0  */
  81.        }  /*  end for  */
  82.       }  /* end main   */
  83.  
  84. void menu1(void)
  85.       {
  86.        mouhidepointer();
  87.        _settextposition(12,12);
  88.        if(menone == 'n')
  89.      {
  90.       printf("menu 1 on ");
  91.       menone = 'y';
  92.      }
  93.        else
  94.     /* if(menone == 'y') */
  95.      {
  96.       printf("menu 1 off");
  97.       menone = 'n';
  98.      }
  99.        moushowpointer();
  100.       }  /* end menu1  */
  101.  
  102. void menu2(void)
  103.       {
  104.        mouhidepointer();
  105.        _settextposition(12,12);
  106.        if(menone == 'n')
  107.      {
  108.       printf("menu 2 on ");
  109.       menone = 'y';
  110.      }
  111.        else
  112.     /* if(menone == 'y') */
  113.      {
  114.       printf("menu 2 off");
  115.       menone = 'n';
  116.      }
  117.        moushowpointer();
  118.       }  /* end menu2  */
  119.  
  120.